package com.yjd.pub.system.service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.system.dto.OperParamDto;
import com.yjd.comm.system.model.MarketParamModel;
import com.yjd.comm.system.service.IMarketParamService;
import com.yjd.comm.util.FrameUtil;
import com.yjd.pub.system.dao.IMarketParamDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * <b>description</b>：系统访问流水日志表业务实现<br>
 * <b>time</b>：2016-02-19 10:48:10 <br>
 * <b>author</b>：  carl
 */
@Service("marketParamService")
public class MarketParamServiceImpl extends BaseServiceImpl implements IMarketParamService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public MarketParamModel insert(MarketParamModel model) throws Exception {
		return this.marketParamDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(MarketParamModel model) throws Exception {
		return this.marketParamDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param id_param
	 * @return
	 * @throws Exception
	 */
	public int delete(long id_param) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id_param", id_param);
		return this.marketParamDao.deleteModel(paramMap, true);
	}

	
	
	
	
	@Override
	public MarketParamModel insert(MarketParamModel model,
			OperParamDto operParamDto) throws Exception {
		this.adminLog(operParamDto, "添加营销推广系统参数[" + FrameUtil.json(operParamDto)
				+ "]", FrameUtil.getTime(null));
		return this.marketParamDao.insertModel(model, true);
	}

	@Override
	public int update(MarketParamModel model, OperParamDto operParamDto)
			throws Exception {
		this.adminLog(operParamDto, "修改营销推广系统参数[" + FrameUtil.json(operParamDto)
				+ "]", FrameUtil.getTime(null));
		return this.marketParamDao.updateModel(model, true);
	}

	@Override
	public int delete(long id_param, OperParamDto operParamDto)
			throws Exception {
		this.adminLog(operParamDto, "删除营销推广系统参数[" + FrameUtil.json(operParamDto)
				+ "]", FrameUtil.getTime(null));
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id_param", id_param);
		return this.marketParamDao.deleteModel(paramMap, true);
	}


    @Override
    public int updateByMap(Map<Object, Object> param, OperParamDto operParamDto) throws Exception {
        this.adminLog(operParamDto, "修改App菜单参数[" + FrameUtil.json(operParamDto) + "]", FrameUtil.getTime(null));
        return this.marketParamDao.updateByMap(param,true);
    }

    @Resource
	private IMarketParamDao marketParamDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.marketParamDao;
	}

}
